#include <57header.h>

// 服务端
int main(int argc,char*argv[])
{
    char *port = "8080";
    char *ip = "192.168.106.129";

    int socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
    
    struct sockaddr_in sockaddr ,    sockaddr_client ;
    sockaddr.sin_family = AF_INET;
    sockaddr.sin_port = htons(atoi(port));
    sockaddr.sin_addr.s_addr = inet_addr(ip);

    bind(socket_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));


    socklen_t len = sizeof(sockaddr_client);
    char buf[60] = {0};
    recvfrom(socket_fd, buf,sizeof(buf), 0, 
             (struct sockaddr *)&sockaddr_client, 
             &len);

    printf("buf: %s \n", buf);

    sendto(socket_fd, "world", 5, 0,
           (struct sockaddr *)&sockaddr_client,
           sizeof(sockaddr_client));


    close(socket_fd);
    return 0;
}

